package o;

import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import org.json.JSONException;
import org.json.JSONObject;

class avm implements avk {
    private final JSONObject ˋ;

    avm(InputStream inputStream) {
        this.ˋ = ॱ(inputStream);
    }

    private JSONObject ॱ(InputStream inputStream) {
        if (inputStream != null) {
            try {
                return new JSONObject(avv.ˊ(inputStream, "UTF-8"));
            } catch (IOException e) {
                Log.e("InputStreamReader", "IOException when reading the 'Config' from InputStream.");
            } catch (JSONException e2) {
                Log.e("InputStreamReader", "JSONException when reading the 'Config' from InputStream.");
            }
        }
        return new JSONObject();
    }

    public String ˎ(String str, String str2) {
        if (str.endsWith("/")) {
            return str2;
        }
        String[] split = str.split("/");
        try {
            JSONObject jSONObject = this.ˋ;
            for (int i = 1; i < split.length; i++) {
                if (i == split.length - 1) {
                    return jSONObject.get(split[i]).toString();
                }
                jSONObject = jSONObject.getJSONObject(split[i]);
            }
            return str2;
        } catch (JSONException e) {
            Log.w("InputStreamReader", "JSONException when reading 'path': " + str);
            return str2;
        }
    }
}
